package com.car.rental.vehicle.controller;

import com.car.rental.common.core.result.ResponseResult;
import com.car.rental.vehicle.entity.VehicleType;
import com.car.rental.vehicle.service.VehicleTypeService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/vehicle/type")
@RequiredArgsConstructor
public class VehicleTypeController {
    
    private final VehicleTypeService vehicleTypeService;
    
    @GetMapping("/list")
    public ResponseResult<List<VehicleType>> list() {
        return ResponseResult.success(vehicleTypeService.listAllSorted());
    }
    
    @PostMapping
    public ResponseResult<Boolean> add(@RequestBody VehicleType vehicleType) {
        return ResponseResult.success(vehicleTypeService.save(vehicleType));
    }
    
    @DeleteMapping("/{id}")
    public ResponseResult<Boolean> delete(@PathVariable Long id) {
        return ResponseResult.success(vehicleTypeService.removeById(id));
    }
} 